<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function geta() {
      return new Promise((resovle, reject) => {

        console.log('请求A数据');
        try {

          setTimeout(() => {
            console.log('A数据请求成功');
            const user = {
              name: 'li'
            }
            resovle(user)
          }, 1000)
        } catch (e) {
          reject(e.message)
        }
      });
    }

    function getb(user) {
      return new Promise((resolve, reject) => {
        console.log('请求B数据');
        try {
          setTimeout(() => {
            console.log("B数据成功");
            const age = {
              age: 18
            }
            resolve({
              ...age,
              ...user
            })
          }, 2000)
        } catch (e) {
          reject(e.message)
        }
      })
    }

    function getc(userage) {
      return new Promise((resolve, reject) => {
        console.log('请求C数据');
        try {
          //throw new Error('错误')
          setTimeout(() => {
            console.log("C数据成功");
            const sex = {
              sex: '男'
            }
            resolve({
              ...userage,
              ...sex
            })
          }, 3000)
        } catch (e) {
          reject(e.message)
        }
      })
    }

    async function getData() {
      const a = await geta()
      console.log(a);
      const b = await getb(a)
      console.log(b);
      const c = await getc(b)
      console.log('数据', c);
      return c
    }
    const get = getData()
    console.log(get);
  </script>
</body>

</html>